[rustdoc] Retrieve cfg_attr information for derived impls for doc_cfg feature - #159722
Merged
Conversation
Collaborator
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer
cc @rust-lang/clippy Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
cfg_attr information for derived impls for doc_cfg featurecfg_attr information for derived impls for doc_cfg feature
Member
Author
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 22, 2026
[rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
GuillaumeGomez
force-pushed
the
cfg_attr-doc_cfg
branch
from
July 22, 2026 15:24
e9bff38 to
42ec8ee
Compare
Member
Author
|
@bors try- |
Contributor
|
Unknown command "try-". Run |
Member
Author
|
@bors try cancel |
Contributor
|
Try build cancelled. Cancelled workflows: |
Member
Author
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 22, 2026
[rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature
Contributor
|
LGTM, r=me when CI and perf are green, unless you want an additional rustdoc review from someone else. |
This comment has been minimized.
This comment has been minimized.
Contributor
This comment has been minimized.
This comment has been minimized.
Contributor
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 23, 2026
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 24, 2026
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
jhpratt
added a commit
to jhpratt/rust
that referenced
this pull request
Jul 24, 2026
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
Rollup of 12 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
rust-bors Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
Rollup of 14 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #158372 (rustfmt: Discover modules via `cfg_select!`) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #159731 (std: Implement futex on wasip3 targets, update target spec) - #159755 (Improve consistency of attribute error messages) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
rust-timer
added a commit
that referenced
this pull request
Jul 24, 2026
Rollup merge of #159722 - GuillaumeGomez:cfg_attr-doc_cfg, r=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes #103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc #43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Jul 25, 2026
Rollup of 14 pull requests Successful merges: - rust-lang/rust#159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - rust-lang/rust#159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - rust-lang/rust#158362 (trait solver: account for universes from replace_bound_vars) - rust-lang/rust#158372 (rustfmt: Discover modules via `cfg_select!`) - rust-lang/rust#159173 (Add allowed list check on EII implementations attributes) - rust-lang/rust#159718 (Make `DocLinkResMap` an `FxIndexMap`) - rust-lang/rust#159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - rust-lang/rust#159731 (std: Implement futex on wasip3 targets, update target spec) - rust-lang/rust#159755 (Improve consistency of attribute error messages) - rust-lang/rust#155795 (constify `vec![1, 2, 3]` macro) - rust-lang/rust#157776 (ci: Enable autodiff tests on x86_64 linux) - rust-lang/rust#158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - rust-lang/rust#159271 (str: add ASCII fast path to word_to_titlecase) - rust-lang/rust#159667 (Make some parser structured suggestions verbose and tweak their wording)
chenyukang
added a commit
to chenyukang/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
chenyukang
added a commit
to chenyukang/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
chenyukang
added a commit
to chenyukang/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
JonathanBrouwer
added a commit
to JonathanBrouwer/rust
that referenced
this pull request
Jul 26, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
rust-timer
added a commit
that referenced
this pull request
Jul 27, 2026
Rollup merge of #159936 - mejrs:ast_docs, r=chenyukang Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in #159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
pull Bot
pushed a commit
to xtqqczze/rust-lang-miri
that referenced
this pull request
Jul 27, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang/rust#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
flip1995
pushed a commit
to flip1995/rust
that referenced
this pull request
Aug 1, 2026
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
github-actions Bot
pushed a commit
to rust-lang/rustc-dev-guide
that referenced
this pull request
Aug 3, 2026
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang/rust#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
flip1995
pushed a commit
to flip1995/rust-clippy
that referenced
this pull request
Aug 17, 2026
Rollup of 14 pull requests Successful merges: - rust-lang/rust#159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - rust-lang/rust#159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - rust-lang/rust#158362 (trait solver: account for universes from replace_bound_vars) - rust-lang/rust#158372 (rustfmt: Discover modules via `cfg_select!`) - rust-lang/rust#159173 (Add allowed list check on EII implementations attributes) - rust-lang/rust#159718 (Make `DocLinkResMap` an `FxIndexMap`) - rust-lang/rust#159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - rust-lang/rust#159731 (std: Implement futex on wasip3 targets, update target spec) - rust-lang/rust#159755 (Improve consistency of attribute error messages) - rust-lang/rust#155795 (constify `vec![1, 2, 3]` macro) - rust-lang/rust#157776 (ci: Enable autodiff tests on x86_64 linux) - rust-lang/rust#158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - rust-lang/rust#159271 (str: add ASCII fast path to word_to_titlecase) - rust-lang/rust#159667 (Make some parser structured suggestions verbose and tweak their wording)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
View all comments
Fixes #103300.
After long last, this PR finally allows the derive proc-macro
cfg_attrcfg predicates information to be kept so rustdoc can use it for itsdoc_cfgfeature (cc #43781).It works as follows: for
implgenerated by macro expansion, we then look for the attributes on the type for which theimplblock is implemented. Then, to know whichcfg_attrattribute we want to look at, we useexpn_that_definedon the impl'sDefIdwhich returns theSpanwhere the macro was expanded. If it's part of acfg_attr, then thecfg_attr'sSpanwill contain the derive's, so from then, we just need to add thecfginformation.This PR also adds the cfg predicates into the
AttributeKind::CfgAttrTracevariant so it can be reused by rustdoc (hence thecompiler/*changes).Thanks a lot @petrochenkov for the pointers here!
r? @petrochenkov